package metro.milano;

import metro.milano.tabimage.Image;
import metro.milano.tabimage.ImageM1;
import metro.milano.tabimage.ImageM2;
import metro.milano.tabimage.ImageM3;
import metro.milano.tabimage.ImageM5;
import android.app.TabActivity;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.view.ViewGroup.LayoutParams;
import android.widget.LinearLayout;
import android.widget.TabHost;

@SuppressWarnings("deprecation")
public class TabView extends TabActivity {

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.tab_static_view);

		Resources res = getResources();
		TabHost tabHost = getTabHost();
		TabHost.TabSpec spec;
		Intent intent;

		intent = new Intent().setClass(this, Image.class);

		spec = tabHost.newTabSpec("Metro").setIndicator("Metro", res.getDrawable(R.drawable.icona_metro)).setContent(intent);
		tabHost.addTab(spec);

		intent = new Intent().setClass(this, ImageM1.class);
		spec = tabHost.newTabSpec("Linea M1").setIndicator("Linea M1", res.getDrawable(R.drawable.m1_icon)).setContent(intent);
		tabHost.addTab(spec);

		intent = new Intent().setClass(this, ImageM2.class);
		spec = tabHost.newTabSpec("Linea M2").setIndicator("Linea M2", res.getDrawable(R.drawable.m2_icon)).setContent(intent);
		tabHost.addTab(spec);

		intent = new Intent().setClass(this, ImageM3.class);
		spec = tabHost.newTabSpec("Linea M3").setIndicator("Linea M3", res.getDrawable(R.drawable.m3_icon)).setContent(intent);
		tabHost.addTab(spec);
		
		intent = new Intent().setClass(this, ImageM5.class);
		spec = tabHost.newTabSpec("Linea M5").setIndicator("Linea M5", res.getDrawable(R.drawable.m5_icon)).setContent(intent);
		tabHost.addTab(spec);

		tabHost.setCurrentTabByTag("Metro");

		LinearLayout layout = (LinearLayout) findViewById(R.id.layoutTab);
		int pixMax = getPIX(this, 76);

		LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, (getWindowManager()
				.getDefaultDisplay().getHeight() - pixMax));
		layout.setLayoutParams(params);

	}

	public static int getPIX(Context context, int dpi) {
		final float scale = context.getResources().getDisplayMetrics().density;
		int mGestureThreshold = (int) (dpi * scale);
		return mGestureThreshold;
	}

}
